var app = getApp();
var ApiUrl = app.globalData.ApiUrl;
var key = "";
Page({
  /**
   * 页面的初始数据
   */
  data: {  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

      key = wx.getStorageSync('key');
      var return_id = options.refund_id;
      var that = this;

      wx.request({
        url: ApiUrl + "/index.php?act=member_return&op=ship_form",
        data: {
          "key": key,
          "return_id": return_id
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        method: 'get',
        success: function (res) {
 
          var return_list = res.data.datas;
          that.setData({
            return_delay: return_list.return_delay,//listBefore.concat(ordergroup),    
            express_list: return_list.express_list,
            return_confirm: return_list.return_confirm,
            return_id: return_list.return_id,
            info:"请选择",
            key: key,
          });

        },
      });
  },
  actionSheetTap: function (e) {

    var that = this;
    var express_id = that.data.express_list[e.detail.value]['express_id'];
    var info = that.data.express_list[e.detail.value]['express_name'];
      
    that.setData({
      express_id: express_id,
      info: info
    });
  },
  formSubmit: function (params) {

    var that = this;
    var paramArr = {};
    paramArr = params.detail.value;
    paramArr.key = that.data.key;
    paramArr.return_id = that.data.return_id;
    
     if (!paramArr.invoice_no) {
      wx.showToast({
        title: '请填写快递单号',
        icon: "loading",
        mask: true,
        duration: 1000,
      });
      return false;
    } else {
      wx.request({
        url: ApiUrl + '/index.php?act=member_return&op=ship_post',
        data: paramArr,
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        method: 'post',
        success: function (result) {
 
          if (result.data.code == "200") {
            wx.redirectTo({
              url: '/pages/member_return/member_return',
            })
          }
        }
      })
    }
  },
})